<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>

</body>
<script>
//(1)对象合并
let o = {username: 'zs'}
let m = {age:20}

//方式1-通过es5,循环
/*
let n = {}
for(let key in o) {
  n[key] = o[key]
}
for(let key in m) {
  n[key] = m[key]
}
*/
//方式2-es6运算符
// let n = {...o, ...m}
//方式3-es6对象方法
// let n = Object.assign({}, o, m)
// console.log(n)

//(2)数组合并
let a = [1,2]
let b = [3,4]
//方式1-通过循环
/*
let c = []
a.forEach(t=> c.push(t))
b.forEach(t=> c.push(t))
*/
// 方式2-es6运算符
// let c = [...a, ...b]
// 方式3-数组方法
// let c = a.concat(b)

console.log(c)
</script>
</html>
